#!/bin/bash
#2018年6月6日20:39:06
#auto install zabbix
#by author www.jfedu.net
#######################
ZBX_VER="3.2.6"
ZBX_SOFT="zabbix-${ZBX_VER}.tar.gz"
ZBX_DIR="/usr/local/zabbix_jfedu"
ZBX_ANT="zabbix_agentd"
ZBX_BAK="/data/backup/20180607"
ZBX_URL="https://jaist.dl.sourceforge.net/project/zabbix/ZBX%20Latest%20Stable/"
ZBX_SER_IP="192.168.0.111"
ZBX_CLI_IP="192.168.0.112"

yum install -y gcc gcc-c++ glibc wget tar make
wget -c $ZBX_URL/$ZBX_SOFT
tar -xzf $ZBX_SOFT
cd zabbix-${ZBX_VER}
./configure --prefix=$ZBX_DIR/ --enable-agent
make
make install
\cp ../zabbix-${ZBX_VER}/misc/init.d/tru64/${ZBX_ANT} /etc/init.d/
chmod o+x /etc/init.d/${ZBX_ANT}
useradd -s /sbin/nologin zabbix
ln -s $ZBX_DIR/sbin/* /usr/local/sbin/

mkdir -p ${ZBX_BAK}
cp $ZBX_DIR/etc/${ZBX_ANT}.conf ${ZBX_BAK}
cat>$ZBX_DIR/etc/${ZBX_ANT}.conf<<EOF
LogFile=/tmp/${ZBX_ANT}.log
Server=${ZBX_SER_IP}
ServerActive=${ZBX_SER_IP}
Hostname = ${ZBX_CLI_IP}
EOF

/etc/init.d/${ZBX_ANT} start
ps -ef|grep zabbix
netstat -tnlp|grep 10050
setenforce 0
systemctl stop firewalld.service
